import request from '@/utils/request'
// 预警处置任务 API接口
const cre_workApi = {
    list: '/cre_work/list',
    save: '/cre_work/save',
    view: '/cre_work/view',
    del: '/cre_work/delete',
    dels: '/cre_work/batchDel',
    output: '/cre_work/output',
    exportExcelTemplate: '/cre_work/exportExcelTemplate',
    importExcel: '/cre_work/importExcel',
    queryList: '/cre_work/queryList',
    updateWorktype: '/cre_work/updateWorktype',
    complete: '/cre_work/complete',
}


/**
 * 预警任务处置完成
 */
 export function complete (id) {
    return request({
        url: cre_workApi.complete,
        method: 'post',
        params: {id}
    })
}

/**
 * 查询预警处置任务关联查询预警信息数据
 */
 export function updateWorktype (workid, warnid, worktype) {
    const requestBody = {
        workid,
        warnid,
        worktype
    }
    return request({
        url: cre_workApi.updateWorktype,
        method: 'post',
        data: requestBody
    })
}

/**
 * 查询预警处置任务关联查询预警信息数据
 */
 export function queryWorkList (pageinfo) {
    return request({
        url: cre_workApi.queryList,
        method: 'post',
        data: pageinfo
    })
}

/**
 * 导入预警处置任务Excel
 */
export function importExcel(data) {
  var body = new FormData()
  body.append("file", data);
  return request({
    url: cre_workApi.importExcel,
    headers: {"Content-Type": "multipart/form-data"},
    method: 'post',
    data: body
  })
}

/**
 * 导出预警处置任务Excel模板
 */
export function exportExcelTemplate () {
    return request({
        url: cre_workApi.exportExcelTemplate,
        method: 'post',
        responseType: 'blob'
    })
}

/**
 * 导出预警处置任务
 */
export function output (data) {
    return request({
        url: cre_workApi.output,
        method: 'post',
        data: data ,
        responseType: 'blob'
    })
}
/**
 * 批量删除预警处置任务
 * @param {*} ids
 */
export function delCre_works (ids) {
    return request({
        url: cre_workApi.dels,
        method: 'post',
        params: {ids}
    })
}
/**
 * 删除预警处置任务
 * @param {*} id
 */
export function delCre_work (id) {
    return request({
        url: cre_workApi.del,
        method: 'post',
        params: {id}
    })
}
/**
 * 查看、编辑预警处置任务
 * @param {*} id
 */
export function viewCre_work (id) {
    return request({
        url: cre_workApi.view,
        method: 'get',
        params: {id}
    })
}
/**
 * 保存预警处置任务
 * @param {*} body
 */
export function saveCre_work (body) {
    return request({
        url: cre_workApi.save,
        method: 'post',
        data: body
    })
}
/**
 * 查询预警处置任务列表
 * @param {*} body
 */
export function queryCre_workList (body) {
    return request({
        url: cre_workApi.list,
        method: 'post',
        data: body
    })
}